//
//  UIImage+Extension.swift
//  HSK-swift-2016
//
//  Created by 刘培壮 on 16/6/7.
//  Copyright © 2016年 上海实奥信息技术有限公司. All rights reserved.
//

import UIKit

extension UIImage {
    
    class func imageWithColor(_ color: UIColor) -> UIImage {
        return imageWithColor(color, size: CGSize(width: 1.0, height: 1.0))
    }

    class func imageWithColor(_ color: UIColor, size: CGSize) -> UIImage {

        let rect = CGRect(x: 0.0, y: 0.0, width: size.width, height: size.height)
        UIGraphicsBeginImageContext(rect.size)
        let context = UIGraphicsGetCurrentContext()
        context!.setFillColor(color.cgColor)
        context!.fill(rect)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image!
        
    }

}

    // MARK: - 常用的image PlaceHolder
extension UIImage {
    class func avartarPlaceholder() -> UIImage {
        return UIImage(named: "img_default_Header")!
    }

}
